﻿using DemoQLKhoSX.DatabaseAccessLayer;
using DemoQLKhoSX.EntityClasses;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace DemoQLKhoSX.BusinessLogicLayer
{
    public class NhaCungCapBLO
    {
        private NhaCungCapDAO _NhaCungCapDAO;

        public NhaCungCapBLO()
        {
            _NhaCungCapDAO = new NhaCungCapDAO();
        }

        public NhaCungCapEntity getNhaCungCapByID(string id)
        {
            NhaCungCapEntity NhaCungCap = new NhaCungCapEntity();
            DataTable tbl = new DataTable();
            tbl = _NhaCungCapDAO.searchByID(id);

            if (tbl != null)
                foreach (DataRow r in tbl.Rows)
                {
                    NhaCungCap.IDNCC = id;
                    NhaCungCap.DiaChi = r["DiaChi"].ToString();
                    NhaCungCap.SoDT = r["SoDT"].ToString();
                    NhaCungCap.TenNCC = r["TenNCC"].ToString();
                }
            return NhaCungCap;
        }
        public List<NhaCungCapEntity> getNhaCC()
        {
            List<NhaCungCapEntity> listNCC = new List<NhaCungCapEntity>();
            DataTable tbl = new DataTable();
            tbl = _NhaCungCapDAO.searchByID("");

            if (tbl != null)
                foreach (DataRow r in tbl.Rows)
                {
                    NhaCungCapEntity nhacc = new NhaCungCapEntity();
                    nhacc.IDNCC = r["IDNCC"].ToString();
                    nhacc.TenNCC = r["TenNCC"].ToString();
                    nhacc.SoDT = r["SoDT"].ToString();
                    nhacc.DiaChi = r["DiaChi"].ToString();
                    listNCC.Add(nhacc);
                }
            return listNCC;
        }
    }
}
